<template>
  <div class="login">
    <div class="welcome">
      <h3>影院系统-客户端</h3>
    </div>
    <div class="login-form">
      <div class="login-inp">
        <label>账号</label>
        <input type="text" placeholder="请输入账号" v-model="user.userName" />
      </div>
      <div class="login-inp">
        <label>密码</label>
        <input type="password" placeholder="请输入密码" v-model="user.password"/>
      </div>
      <div class="login-inp"><a href="#" @click="toLogin">立即登录</a></div>
    </div>
    <div class="login-txt">
      <router-link tag="a" to="/register">立即注册</router-link>
      <router-link tag="a" to="/resetPassword">忘记密码？</router-link>
    </div>
  </div>
</template>

<script>
import { login } from '@/api/user'
export default {
  name: 'login',
  data() {
    return {
      user:{
        userName:'customer',
        password:'lzp666'
      }
    }
  },
  methods:{
    toLogin(){
      login(this.user).then(response => {
        if (response.code === '200') {
          this.$notify({
            message:response.message,
            type: 'success'
          })
          // 同步调用存储用户在vux中
          localStorage.setItem('user',JSON.stringify(response.data))
          localStorage.setItem('token',JSON.stringify(response.data.token))
          this.$store.commit('updateUser', response.data);
          this.$store.commit('updateToken', response.data.token);
          this.$router.push('/index')
        }
      })
    }
  }
  
};
</script>

<style>
@charset "utf-8";
  .welcome h3 {
    color:white;
    font-size: 40px;
    text-align: center;
  }
  div,
  p,
  form,
  label,
  ul,
  li,
  dl,
  dt,
  dd,
  ol,
  img,
  button,
  b,
  em,
  strong,
  small,
  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    margin: 0;
    padding: 0;
    border: 0;
    list-style: none;
    font-style: normal;
  }
  .login {
    font-family: SimHei, "Helvetica Neue", Arial, "Droid Sans", sans-serif;
    font-size: 14px;
    color: #333;
    background: #f2f2f2;
  }
  a,
  a.link {
    color: #666;
    text-decoration: none;
    font-weight: 500;
  }
  a,
  a.link:hover {
    color: #666;
  }
  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    font-weight: normal;
  }

  .login {
    width: 100%;
    height: 100%;
    background: url(../../assets/login-bg.png) no-repeat;
    background-size: cover;
    position: fixed;
    z-index: -10;
  }
  .welcome {
    width: 100%;
    margin: 25% 0;
  }
  .welcome img {
    width: 100%;
  }
  .login-inp {
    margin: 0 30px 15px 30px;
    border: 1px solid #fff;
    border-radius: 25px;
  }
  .login-inp label {
    width: 4em;
    text-align: center;
    display: inline-block;
    color: #fff;
  }
  .login-inp input {
    line-height: 40px;
    color: #fff;
    background-color: transparent;
    border: none;
    outline: none;
  }
  .login-inp a {
    display: block;
    width: 100%;
    text-align: center;
    line-height: 40px;
    color: #fff;
    font-size: 16px;
    letter-spacing: 5px;
  }
  .login-txt {
    text-align: center;
    color: #fff;
  }
  .login-txt a {
    color: #fff;
    padding: 0 5px;
  }
</style>